export enum Status {
  OK = 200,
  BadRequest = 400,
  Unauthorized = 401,
  Forbidden = 403,
  NotFound = 404,
  MethodNotAllowed = 405,
  InternalServerError = 500
}

export class ReqStat {
  stat: string
  msg: string
  statusCode: number

  constructor(stat: string, msg: string, statusCode: number = Status.OK) {
    this.stat = stat
    this.msg = msg
    this.statusCode = statusCode
  }
}

export function badParams(msg: string) {
  return new ReqStat('ERR_PARAMS', msg, Status.BadRequest)
}

export const stats = {
  ERR_NOT_FOUND: new ReqStat('ERR_NOT_FOUND', '记录不存在'),
  ERR_NOT_LOGIN: new ReqStat('ERR_NOT_LOGIN', '用户未登录'),
  ERR_FORBIDDEN: new ReqStat('ERR_FORBIDDEN', '禁止'),
  ERR_NOT_RIGHT: new ReqStat('ERR_NOT_RIGHT', '权限不足'),
  ERR_REPEAT: new ReqStat('ERR_REPEAT', '已经存在该记录'),
  ErrNotFound: new ReqStat('ErrNotFound', '找不到指定记录'),
  ERR_PASSWORD: new ReqStat('ERR-PASSWORD', '密码不能与原来一样'),
  ERR_old_PASSWORD: new ReqStat('ERR_old_PASSWORD', '原密码错误'),
  ERR_FIRBID_CAR: new ReqStat('ERR_FIRBID_CAR', '禁止将自己的书加入购物车'),
  ERR_FIRBID_FOLLOW: new ReqStat('ERR_FIRBID_FOLLOW', '禁止关注自己'),
  ERR_LOGIN_FAILED: new ReqStat('ERR_LOGIN_FAILED', '密码错误,请输入正确密码')
}
